package com.tank.bean;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

@Entity
public class Notice {

	
	public static final String Buddy = "buddy";
	public static final String Comment = "comment";
	public static final String Item = "item";
	public static final String Message = "message";
	public static final String At = "at";


	@GenericGenerator(name = "gen", strategy = "increment")
	@Id
	@GeneratedValue(generator = "gen")
	private Integer id;//标识
	
	
	private String author;//system
	
	private String content;//[]
	
	
	@ManyToOne(fetch=FetchType.LAZY)
	private User master;
	@ManyToOne(fetch=FetchType.LAZY)
	private User target;
	
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date readtime;
	@Temporal(TemporalType.TIMESTAMP)
	private Date pubtime;
	
	private String type;// 1,fans 2,comment 3,message 4,item
	
	public Notice(){}
	public Notice(User master,User target, String content) {
		this.master=master;
		this.target=target;
		this.content=content;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public User getMaster() {
		return master;
	}
	public void setMaster(User master) {
		this.master = master;
	}
	public User getTarget() {
		return target;
	}
	public void setTarget(User target) {
		this.target = target;
	}
	public Date getReadtime() {
		return readtime;
	}

	public void setReadtime(Date readtime) {
		this.readtime = readtime;
	}
	public Date getPubtime() {
		return pubtime;
	}

	public void setPubtime(Date pubtime) {
		this.pubtime = pubtime;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	@Override
	public String toString() {
		StringBuilder sb=new StringBuilder();
		sb.append("{");
		sb.append("id").append(id).append(",");
		sb.append("author").append(author).append(",");
		sb.append("content").append(content).append(",");
		//sb.append("to").append(to).append(",");
		sb.append("type").append(type).append(",");
		sb.append("readtime").append(readtime).append(",");
		sb.append("pubtime").append(pubtime).append(",");
		sb.append("}");
		
		return sb.toString();
	}
	
}
